home *** CD-ROM | disk | FTP | other *** search
- on acrobatWindowIDs
- set taskIDs to getNamedTasks("Acrobat")
- set theCount to count(taskIDs)
- if theCount < 1 then
- warning("acrobatWindowIDs(): no Acrobat tasks")
- return []
- end if
- set windowIDs to []
- repeat with i = 1 to theCount
- set thisTaskID to getAt(taskIDs, i)
- set thisWindowIDs to getTaskWindowIDs(thisTaskID)
- if word 1 of thisWindowIDs <> "Error:" then
- set nw to the number of words in thisWindowIDs
- if nw >= 1 then
- repeat with j = 1 to nw
- set thisWindowText to word j of thisWindowIDs
- set thisWindowID to integer(thisWindowText)
- if integerp(thisWindowID) then
- if not windowExists(thisWindowID) then
- next repeat
- end if
- if not windowHasChildren(thisWindowID) then
- next repeat
- end if
- if windowParent(thisWindowID) <> 0 then
- next repeat
- end if
- if not (windowName(thisWindowID) contains "Acrobat Reader") then
- next repeat
- end if
- if not (windowType(thisWindowID) contains "Afx:") then
- next repeat
- end if
- add(windowIDs, thisWindowID)
- end if
- end repeat
- end if
- end if
- end repeat
- if count(windowIDs) < 1 then
- warning("acrobatWindowIDs(): no Acrobat windows")
- return []
- end if
- return windowIDs
- end
-
- on acrobatWindowID
- set windowIDs to acrobatWindowIDs()
- if count(windowIDs) > 1 then
- warning("acrobatWindowID(): ambiguous: more than one Acrobat window")
- return 0
- end if
- if count(windowIDs) < 1 then
- warning("acrobatWindowID(): no Acrobat window")
- return 0
- end if
- return getAt(windowIDs, 1)
- end
-
- on killAllAcrobatTasks
- global gShowWarning
- set oldWarning to gShowWarning
- hideWarnings()
- set windowIDs to acrobatWindowIDs()
- if oldWarning then
- showWarnings()
- end if
- set theCount to count(windowIDs)
- if theCount < 1 then
- return 1
- end if
- set success to 1
- set killed to 1
- set tasksToCheck to []
- repeat with i = 1 to theCount
- set thisWindowID to getAt(windowIDs, i)
- set theTask to getWindowTask(thisWindowID)
- add(tasksToCheck, theTask)
- if not windowExists(thisWindowID) then
- next repeat
- end if
- cancelAnyDialogs(thisWindowID)
- closeWindow(thisWindowID)
- set giveUpTicks to the ticks + (10 * 60)
- set killed to 0
- repeat while the ticks < giveUpTicks
- if not windowExists(thisWindowID) then
- set killed to 1
- exit repeat
- end if
- feedTimeSlice(theTask)
- feedGenericTimeSlice()
- end repeat
- if not killed then
- warning("killAllAcrobatTasks(): ten second timeout while killing window " & i & " of " & theCount)
- set success to 0
- end if
- end repeat
- if success <> 1 then
- warning("killAllAcrobatTasks(): not all windows killed")
- return 0
- end if
- set giveUpTicks to the ticks + 30
- repeat while the ticks < giveUpTicks
- feedGenericTimeSlice()
- end repeat
- set theCount to count(tasksToCheck)
- if theCount < 1 then
- return 1
- end if
- set giveUpTicks to the ticks + (10 * 60)
- repeat while the ticks < giveUpTicks
- set thisTask to getAt(tasksToCheck, 1)
- if taskIsRunning(thisTask) then
- rudeQuitTask(thisTask, 0)
- else
- deleteAt(tasksToCheck, 1)
- end if
- feedGenericTimeSlice()
- if count(tasksToCheck) = 0 then
- windowToFront(directorMainWindow())
- return 1
- end if
- end repeat
- warning("killAllAcrobatTasks(): ten-second timeout, not all tasks killed")
- return 0
- end
-